//package com.qtt.app.controller;
//
//import com.qtt.app.common.ApiResponse;
//import com.qtt.app.entity.Test.MsgBoard;
//import com.qtt.app.service.MsgBoardService;
//import io.swagger.annotations.Api;
//import io.swagger.annotations.ApiOperation;
//import io.swagger.annotations.ApiParam;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.web.bind.annotation.*;
//
//import java.util.List;
//
//
//@Api(tags = "MsgController", description = "信息管理(测试数据库用的)")   //tags是api名字，description是简介，value:已废用
//@RestController
//@RequestMapping("/Msg")
//public class MsgBoardController {
//    @Autowired
//    MsgBoardService msgBoardService;
//
//    @ApiOperation(value = "查询所有", notes = "可以查看msg表中的所有数据")  //value是Get /Msg/list旁边的那个api简介；notes是点开的介绍，可用于详细说明api作用
//    @GetMapping("/list")
//    public ApiResponse<List<MsgBoard>> listall(){
////    public List<MsgBoardEntity> listall(){
//        msgBoardService.listAll();
//        List<MsgBoard> entities = msgBoardService.listAll();
////        return entities;
//        return ApiResponse.<List<MsgBoard>>builder().code(200).message("查看成功").data(entities).build();
//    }
//
//    @ApiOperation(value = "添加一条新的记录", notes = "结构体里面的id，gmt_create都不用填，只需要传入author和msg。")
//    //@RequestBody 是json传值
//    @PostMapping("/list")
//    public ApiResponse<String> addMsg(@ApiParam("传入的是msg实体，id和gmt_create都不用填")@RequestBody MsgBoard entity){
////    public String addMsg(@RequestBody MsgBoardEntity entity){
//        Boolean b = msgBoardService.addMsg(entity);
//        if (b == true){
//            return ApiResponse.<String>builder().code(200).message("添加成功").data(b.toString()).build();
//        }
//        else {
//            return ApiResponse.<String>builder().code(400).message("添加失败").data(b.toString()).build();
//        }
//    }
//
//    @ApiOperation(value = "删除一条记录", notes = "哈哈哈")
//    //注意是@PathVariable 不是@PathParam ；这个是路径传值
//    @DeleteMapping("/list/{id}")
////    public String deleteMsg(@PathVariable("id") long id){
//    public ApiResponse<String> deleteMsg(@PathVariable("id") long id){
//        Boolean b = msgBoardService.delete(id);
//
//        if (b == true){
//            return ApiResponse.<String>builder().code(200).message("删除成功").data(b.toString()).build();
//        }
//        else {
//            return ApiResponse.<String>builder().code(400).message("删除失败").data(b.toString()).build();
//        }
//    }
//
//    @ApiOperation(value = "修改一条记录", notes = "哈哈哈")
//    //注意是@PathVariable 不是@PathParam ；这个是路径传值
//    @PutMapping("/list/{id}")
//    public ApiResponse<String> updateMsg(@RequestParam("id") long id, @ApiParam("发送的信息")@RequestParam("msg") String msg){
//        Boolean b = msgBoardService.update(id,msg);
//        if (b == true){
//            return ApiResponse.<String>builder().code(200).message("修改成功").data(b.toString()).build();
//        }
//        else {
//            return ApiResponse.<String>builder().code(400).message("修改失败").data(b.toString()).build();
//        }
//    }
//}
